/*
*************************************************
				Copyagent
	------------------------------------------
	            crawler_lib.h
*************************************************
Semnaturile functiilor din crawler_lib.c
*/

/*
crawler_lib.h
*/
#ifndef CRAWLER_LIB_H
#define CRAWLER_LIB_H

#define MIN_URL_LEN 6

//Lista url-urilor de parcurs
typedef struct URLList
{
	char * url;  //URL to be read
	struct URLList * next; //next URL in list

} urlListNode, * TurlListNode;

/* 
*Posibilele stari in care ne putem afla cand se citeste un HTML
* HTML-	ne aflam deja intr-un tag HTML. A fost deschisa in prealabil un TAG_OPEN
* URL-	ne aflam deja intr-un href="http://		
*/
enum overlap_flags {HTML,URL,TEXT};

/* 
Citeste lista initiala a link-urilor si initializeaza utlList-ul corespunzator
return value: 0 - in caz de succes ; 1 - altfel
filename: calea relativa la fisierul de configurare
lista: pointer la lista de url-uri
*/
extern int readFile(char * filename, struct URLList * lista);

/*
getNode: scoate din lista urmatorul nod
return: nodul scos
lista: pointer la lista de url-uri
*/
extern urlListNode * getNode(struct URLList * lista);


/*
insertNode: insereaza un nod in lista
url: url-ul de inserat
lista: listaUrl-urilor
*/
extern int insertNode(char * url, struct URLList * lista);


extern urlListNode * getFirstNode(struct URLList * lista);
extern urlListNode * getLastNode(struct URLList * lista);
extern void debugPrint(int node_rank, char* message);
extern int replaceChars(char * sir, char toReplace, char replacer);
extern char * extrageHostDinURL(char * URL);
extern int parse_buffer(char* buffer, char * url_buffer, char * prop_buffer);
extern char * denumeste_prop_file(char * url, int rank);
extern char * denumeste_link_file(char * url, int rank);
extern char * normalizez_nume_fisier(char * nume);
extern int sparge_link_bufferul
(char * buffer, FILE * dest_file, char * url_curent, struct URLList * lista);
extern int sparge_prop_bufferul(char * buffer, FILE * dest_file);
extern char * adauga_rel_la_abs(char * absolut, char * relativ);
extern int extensia_e_valida(char * url);
extern char * canonizeaza_url(char * url);
extern void afiseaza_lista_url(struct URLList * lista);
#endif
